<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS打字机效果</title>
    <style>
        * {
            margin: 0;
            border: 0;
            box-sizing: border-box;
        }
        #container {
  
            line-height: 50vh;
            background-color: #222;
            height: 100vh;
            width: 100vw;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .content {
            font-size: 40px;
            color: beige;
            overflow: hidden;
            white-space: nowrap;
            animation: typing 3s steps(30, end) 1s infinite alternate, blink 500ms steps(20, end) infinite;
            letter-spacing: 5px;
            max-width: max-content;
            border-right: 2px solid orange;
        }
        @keyframes typing {
            from {
                width: 0;
            }
            to {
                width: 100%;
            }
        }
        @keyframes blink {
            50% {
                border-color: transparent;
            }
        }
    </style>
</head>
<body>
    <div id="container">
        <div class="content">
            欢迎学习CSS打字机，参观我的主页可以学习更多
        </div>
    </div>
</body>

<script>
    document.addEventListener("DOMContentLoaded", function() {
        const contentElement = document.getElementsByClassName('content')[0];
        const initialText = "欢迎学习CSS打字机，参观我的主页可以学习更多";
        const newText = "记得来学习";
        const intervalTime = 13000; 

        let showingInitialText = true;

        setInterval(() => {
            if (showingInitialText) {
                contentElement.textContent = newText;
            } else {
                contentElement.textContent = initialText;
            }
            showingInitialText = !showingInitialText;
        }, intervalTime);
    });
</script>
</html>
